<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.Room"
         import="com.shxt.hotel.background.User"
         import="java.util.List"
         import="java.util.Map"
%>
<%
    Room room = new Room();
    User user = new User();
    
    Map<String, Object> currentUser;
    
    if(session.getAttribute("id") == null){
        response.sendRedirect("./login.jsp");
    }else{
        currentUser = user.getUserInfo((int)session.getAttribute("id"));
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="../Public/img/favicon.html">

    <title>Hotel Booking</title>

    <!-- Bootstrap core CSS -->
    <link href="../Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="../Public/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="../Public/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="../Public/css/style.css" rel="stylesheet">
    <link href="../Public/css/style-responsive.css" rel="stylesheet" />
    <!--date range style-->
    <link rel="stylesheet" href="../Public/css/date_range.css">
    <!--style for datapicker-->
    <link rel="stylesheet" href="../Public/css/calendar.css">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="../Public/js/html5shiv.js"></script>
      <script src="../Public/js/respond.min.js"></script>
    <![endif]-->
    <!-- js placed at the end of the document so the pages load faster -->
    <script src="../Public/js/jquery.js"></script>
    <script src="../Public/js/bootstrap.min.js"></script>
    <script src="../Public/js/jquery.scrollTo.min.js"></script>
    <script src="../Public/js/jquery.nicescroll.js" type="text/javascript"></script>
    
</head>

<body>

    <section id="container" class="">
        <!--header start-->
        <jsp:include page="./Public/header.jsp" flush="true"/>
        <!--header end-->
        <!--sidebar start-->
        <jsp:include page="./Public/sidebar.jsp" flush="true"/>
        <!--sidebar end-->
        <!--main content start-->
        <section id="main-content">
            <section class="wrapper">
                <!-- page start-->
                <div class="row">
                    <div class="col-lg-12">
                        <section class="panel">
                            <header class="panel-heading">
                                Room Booking
                            </header>
                            <div class="panel-body">
                                <div class="stepy-tab">
                                    <ul id="default-titles" class="stepy-titles clearfix">
                                        <li id="default-title-0" class="current-step">
                                            <div>Step 1</div>
                                        </li>
                                        <li id="default-title-1" class="">
                                            <div>Step 2</div>
                                        </li>
                                    </ul>
                                </div>
                                <form class="form-horizontal" id="default" action="./background/hotel_booking_do.jsp" method="post">
                                    <fieldset title="Step1" class="step" id="default-step-0">
                                        <legend> </legend>
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <section class="panel">
                                                    <table class="table table-striped table-advance table-hover">
                                                        <thead>
                                                        <tr>
                                                            <th><i class="icon-bullhorn"></i> Room Type</th>
                                                            <th class="hidden-phone"><i class="icon-question-sign"></i> Room Num</th>
                                                            <th><i class="icon-bookmark"></i> Price</th>
                                                            <th><i class="icon-edit"></i> Wifi</th>
                                                            <th>Bathroom</th>
                                                            <th>Area</th>
                                                            <th>Status</th>
                                                            <th>Operation</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <%
                                                            // get all rooms
                                                            List<Map<String, Object>> roomList = room.getRooms();
                                                            List<Map<String, Object>> categoryList = room.getCategories("*");
                                                            
                                                            for(int i = 0; i < roomList.size(); i++){
                                                                Map<String, Object> room_rec = roomList.get(i);
                                                                int roomCategory = (int)room_rec.get("category");
                                                                Map<String, Object> cate = categoryList.get(roomCategory);
                                                        %>
                                                            <tr class="odd gradeX" id='hotel_booking_room_tr_<%=room_rec.get("id") %>'>
                                                                <td form-data="room_category"><a href="#"><%=cate.get("title") %></a></td>
                                                                <td class="hidden-phone" form-data="id"><%=room_rec.get("id") %></td>
                                                                <td class="hidden-phone" form-data="price"><%=cate.get("price") %><span class="icon-dollar"></span></td>
                                                                <td class="hidden-phone" form-data="wifi"><%=(Boolean)cate.get("wifi") == true ? "Yes" : "No"%></td>
                                                                <td class="hidden-phone" form-data="bathroom"><%=(Boolean)cate.get("bathroom") == true ? "Yes" : "No"%></td>
                                                                <td class="hidden-phone" form-data="area"><%=cate.get("area_min") + " ~ " + cate.get("area_max") + "mm" %></td>
                                                                <td class="hidden-phone" form-data="is_sub"><%=(Boolean)room_rec.get("is_sub") == true ? "Yes" : "No" %></td>
                                                                <td class="hidden-phone">
                                                                        <button class="btn btn-info btn-xs room_book_button" form-data='<%=room_rec.get("id") %>' type="button">
                                                                            <i class="icon-edit"></i> Book
                                                                        </button>
                                                                </td>
                                                            </tr> 
                                                        <%
                                                            }
                                                        %>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    Adimin co
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>56456.00$ </td>
                                                            <td><span class="label label-warning label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    boka soka
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>14400.00$ </td>
                                                            <td><span class="label label-success label-mini">Paid</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    salbal llb
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>2323.50$ </td>
                                                            <td><span class="label label-danger label-mini">Paid</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><a href="#">Vector Ltd</a></td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo imit</td>
                                                            <td>12120.00$ </td>
                                                            <td><span class="label label-primary label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    Adimin co
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>56456.00$ </td>
                                                            <td><span class="label label-warning label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><a href="#">Vector Ltd</a></td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo imit</td>
                                                            <td>12120.00$ </td>
                                                            <td><span class="label label-success label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    Adimin co
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>56456.00$ </td>
                                                            <td><span class="label label-warning label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><a href="#">Vector Ltd</a></td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo imit</td>
                                                            <td>12120.00$ </td>
                                                            <td><span class="label label-info label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="#">
                                                                    Adimin co
                                                                </a>
                                                            </td>
                                                            <td class="hidden-phone">Lorem Ipsum dorolo</td>
                                                            <td>56456.00$ </td>
                                                            <td><span class="label label-warning label-mini">Due</span></td>
                                                            <td>
                                                                <button class="btn btn-success btn-xs"><i class="icon-ok"></i></button>
                                                                <button class="btn btn-primary btn-xs"><i class="icon-pencil"></i></button>
                                                                <button class="btn btn-danger btn-xs"><i class="icon-trash "></i></button>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </section>
                                            </div>
                                        </div>

                                    </fieldset>
                                    <fieldset title="Step 2" class="step" id="default-step-1">
                                        <legend> </legend>
                                        <section class="panel">
                                            <header class="panel-heading">Room Info</header>
                                            <div class="panel-body">
                                                
                                                <!-- room id -->
                                                <input id="book_room_id" type="hidden" name="rid" value="">
                                                <input type="hidden" name="uid" value='<%=currentUser.get("id") %>'>
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">Room Type</label>
                                                    <div class="col-lg-10">
                                                        <p class="form-control-static" id="room_info_room_category">Deluxe Room</p>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">Date Ranges</label>
                                                    <span>
                                                        <span class="col-lg-3">
                                                            <input id="room_book_create_time" class="form-control" type="text" name="create_date" value="">
                                                        </span>
                                                        <span class="col-lg-3">
                                                            <input id="room_book_end_time" class="form-control" type="text" name="end_time" value="">
                                                        </span>
                                                    </span>
                                                </div>
                                                <input id="room_book_total_time" type="hidden" name="total_time" value="">
                                                <div class="form-group">
                                                    <label class="control-label col-lg-2" for="inputSuccess">Room Number</label>
                                                    <div class="col-lg-3">
                                                        <select class="form-control m-bot15">
                                                            <option>1</option>
                                                            <option>2</option>
                                                            <option>3</option>
                                                            <option>4</option>
                                                            <option>5</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">Total Cost</label>
                                                    <div class="col-lg-10">
                                                        <p class="form-control-static">
                                                            <span class="text-danger" id="room_info_price">233.3</span><span class="icon-dollar text-danger"></span>
                                                        </p>
                                                        <input id="room_info_deposit" type="hidden" name="deposit" value="">
                                                    </div>
                                                </div>
                                            </div>
                                            
                                        </section>
                                        
                                        <section class="panel">
                                            <header class="panel-heading">User Info</header>
                                            <div class="panel-body">
                                                
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">User ID</label>
                                                    <div class="col-lg-10">
                                                        <p class="form-control-static"><%=currentUser.get("username") %></p>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">Phone</label>
                                                    <div class="col-lg-10">
                                                        <p class="form-control-static"><%=currentUser.get("phone") %></p>
                                                    </div>
                                                </div>
                                                
                                            </div>
                                        </section>

                                    </fieldset>
                                    <input type="submit" class="finish btn btn-danger" value="Submit" />
                                </form>
                            </div>
                        </section>
                    </div>
                </div>
                <!-- page end-->
            </section>
        </section>
        <!--main content end-->
    </section>
    
    <!--common script for all pages-->
    <script src="../Public/js/common-scripts.js"></script>

    <!--script for this page-->
    <script src="../Public/js/jquery.stepy.js"></script>

    
    <!--script by myself-->
    <script src='../Public/js/myself-ele2obj.js'></script>

    <script>
      //step wizard
      $(function() {
          $('#default').stepy({
              backLabel: 'Previous',
              block: true,
              nextLabel: 'Next',
              titleClick: true,
              titleTarget: '.stepy-tab'
          });
      });
    </script>
    
    <!--scripted by myself-->
    <script src='../Public/Cus/js/ele2obj.js'></script>
    <script src='../Public/Cus/js/home-hotel-booking.js'></script>
    <script>
        $("#room_book_create_time").on("blur", getRoomBookTime);
        $("#room_book_end_time").on("blur", getRoomBookTime);
        
        function getRoomBookTime(){
            var createDate = new Date($("#room_book_create_time").val());
            var endDate = new Date($("#room_book_end_time").val());
            // alert(createDate.getMonth());
            var create_mi = Date.UTC(createDate.getFullYear(), createDate.getMonth(), createDate.getDate());
            var end_mi = Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
            var mi = (end_mi - create_mi) / (1000 * 60 * 60 * 24) + 1;
            $("#room_book_total_time").val(mi);
        }
    </script>


</body>

</html>
<%
    }
    room.close();
%>